<!doctype html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="__TMPL__Public/assets/book_static/css/base.css" />
<link rel="stylesheet" href="__TMPL__Public/assets/book_static/css/info-mgt.css" />
<link rel="stylesheet" href="__TMPL__Public/assets/book_static/css/WdatePicker.css" />
<link rel="stylesheet" href="__TMPL__Public/assets/layui/css/layui.css">
<link rel="stylesheet" href="__TMPL__Public/assets/book_static/css/pager.css">
<script type="text/javascript" src="__TMPL__Public/assets/book_static/js/jquery.js"></script>
<script type="text/javascript" src="__TMPL__Public/assets/layui/layui.js"></script>
<title>图书库存管理系统</title>
</head>

<body>
<div class="title"><h2>信息维护</h2></div>
<div class="query">
	<form target="_self" action="" method="GET" id= "dosearch">
		<input type="hidden" name="m" value="index">
		<input type="hidden" name="a" value="list_kuwei">
		<div class="query-conditions ue-clear">
			<div class="conditions staff ue-clear">
				<label>位置：</label>
				<input type="text" name="location" id="location" placeholder="直接输入位置进行查询" value="{$data.searchlocation}" />
			</div>
		   
		</div>
		<div class="query-btn ue-clear">
			<a href="javascript:$('#dosearch').submit();" class="confirm">查询</a>
			<a href="javascript:$('#location').val('');" class="clear">清空条件</a> 
			
		</div>
		
		
		
			
	</form>
	
</div>


<div class="table-box">
	<table>
    	<thead>
        	<tr>
            	<th class="num">序号</th>
                <th class="name">位置</th>
                <th class="node">库存数量</th>
                <th class="operate">操作</th>
            </tr>
        </thead>
        <tbody>
			<foreach name="data.list" item="vo" key="k">
        	<tr class="{$vo.id}">
            	<td class="num">{$vo.id}</td>
                <td class="process">{$vo.location}</td>
                <td class="name">{$vo.count}</td>
                <td class="operate">
				<a href="javascript:void(0);delsure('{$vo.location}')">删除</a> 
				</td>
            </tr>
			</foreach>
        </tbody>
    </table>
</div>


<div class="pxofy">当前显示第&nbsp;{$data.page}&nbsp;页，共&nbsp;{$data.total}&nbsp;页&nbsp合计&nbsp;{$data.count}&nbsp;条数据 前往
	<select name="pageselect" id="pageselect" style="padding:4px;">
	<?php
	for($i=1;$i<=$data["total"];$i++){
		$selectedstr = '';
		if($data["page"]==$i){
			$selectedstr = "selected";
		}else{
			$selectedstr = "";
		}
		echo "<option value='".$i."'".$selectedstr.">第".$i."页</option>";
	}
	?>
	</select>
</div>
<div class="page-control ue-clear"></div>


</body>
<script type="text/javascript" src="__TMPL__Public/assets/book_static/js/jquery.page.js"></script>
<script type="text/javascript" src="__TMPL__Public/assets/book_static/js/common.js"></script>
<script type="text/javascript" src="__TMPL__Public/assets/book_static/js/WdatePicker.js"></script>
<script type="text/javascript" src="__TMPL__Public/assets/book_static/js/jquery.pagination.js"></script>

<script type="text/javascript">
$(".select-title").on("click",function(){
	$(".select-list").hide();
	$(this).siblings($(".select-list")).show();
	return false;
})
$(".select-list").on("click","li",function(){
	var txt = $(this).text();
	$(this).parent($(".select-list")).siblings($(".select-title")).find("span").text(txt);
})

// 分页器
$(".page-control").createPage({
	pageCount:{$data.total},  //总页数
	current:{$data.page},     //当前页数
	callbackFn:function(page){
		var index = layer.load(0, {shade: 0.1}); //0代表加载的风格，支持0-2
		var pageurl = '{$data.pageurl}';
		window.location.href=pageurl+"&page="+page; 
	}
});

layui.use('upload', function(){
	var $ = layui.jquery
	,upload = layui.upload;
	upload.render({
		elem: '#test8'
		,url: "/index.php?g=&m=index&a=upisbn"
		,accept: 'file'
		,auto: false
		//,multiple: true
		,bindAction: '#test9'
		,before: function(res){
			layer.load(3); //上传loading
		}
		,done: function(res){
			if(res.state=="fail"){
				layer.closeAll('loading');
				layer.msg('导入失败，'+res.message, {time: 5000, icon:5,shade: 0.7});
			}else{
				layer.closeAll('loading');
				layer.msg('导入成功！', {time: 5000, icon:6,shade: 0.7});
				window.location.reload();
			}
		},error: function(index, upload){
			layer.closeAll('loading');
		}
	});
});

//select 分页器
$("#pageselect").change(function(){
	var index = layer.load(0, {shade: 0.1}); //0代表加载的风格，支持0-2
	var pageurl = '{$data.pageurl}';
	var page = $(this).val();
	window.location.href=pageurl+"&page="+page; 
})

$("tbody").find("tr:odd").css("backgroundColor","#eff6fa");



function delsure(location){
	if(location==""){
		layer.msg('参数错误！', {icon: 2});return;
	}
	layer.confirm('删除库位后，该库位下的库存数据将被清除是否确认删除该库位？', {
		icon: 3,
		btn: ['确认','取消'] //按钮
	}, function(){
		var url = "{:U('index/delkuwei')}&location="+location;
		window.location.href=url;
	});
}

</script>
</html>
